package org.szw.jpademo.dao;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.szw.jpademo.entity.User;

import java.util.List;

/**
 * @Description
 * @Author 申紫微
 * @Data 2020-06-05 17:32:00
 * @Version 1.0
 */
@Repository
public interface UserDao extends JpaRepository<User,Long> {

    public List<User> findByEmail();

    /**基于@Query注解查询 JPQL语句和HQL语句类似*/
    @Query(value = "from User where name like ?1")
    User queryUserByNameV1(String name);

    /**
     * @Description 使用原生SQL
     **/
    @Query(value = "select * from User where name like ?1",nativeQuery = true)
    User queryUserByNameV2(String name);



}
